package com.it.you.file;

import javax.swing.*;
import java.awt.*;

/**
 * @Author : YouHui
 * @create 2023/5/29 12:19
 */
public class FileImportDemo {

    public static void main(String[] args) {
        JFrame frame = new JFrame("文件导入");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 150);
        frame.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 20));

        JButton importButton = new JButton("导入文件");
        JProgressBar progressBar = new JProgressBar(0, 100);
        progressBar.setStringPainted(true);

        importButton.addActionListener(e -> {
            // 设置导入文件路径和超时时间
            String filePath = "/Users/youhui/Desktop/智药通账期流水推送最终字段.txt";
            int timeout = 100000; // 10 秒
            FileImportWorker worker = new FileImportWorker(progressBar, filePath, timeout);
            worker.execute();
        });

        frame.add(importButton);
        frame.add(progressBar);
        frame.setVisible(true);
    }

}
